<?php
// 本类由系统自动生成，仅供测试用途
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function login(){
             $this->display();
    }

    
    public function going(){
 
            if(isset($_POST))
            { 
                        $map['username'] = $_POST["username"];
                        $map['password'] = md5(sha1($_POST["password"]));
        
                         $Data= M('admin');// 实例化Data数据模型
                          $arr=$Data->field('id')->where($map)->find();
                        
                 if ($arr>0 )
                     
                        {       session('state','login');
                                session('yj_user',$_POST['username']);
                                    $data['msg']="登陆成功，欢迎回来!";
                                   $this->ajaxReturn($data);
                            
                          }
                        else
                        {      
                                $data['msg']="用户名密码错误！";
                                $this->ajaxReturn($data);
                            
                        }
          }
          else
          {
              $this->error('非法操作哦');
          }
                               
                        } 
                               

                 public function logout()  {
                      $_SESSION=array();
                        if(isset($_COOKIE[session_name()])){
                          setcookie(session_name(),'',time()-1,'/');
                        }
                      session_destroy();
                      $this->redirect('login/login');
                    }
               
}